//
//  ChooseCityController.m
//  renmingongshe
//
//  Created by Mao on 2017/11/8.
//  Copyright © 2017年 xiaodian. All rights reserved.
//

#import "ChooseCityController.h"

@interface ChooseCityController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *_table;
}
@end

@implementation ChooseCityController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.titleLabel.text = @"选择城市";
    
    [self createTable];
}

- (void)createTable
{
    _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 70, WIDTH, HEIGHT-70) style:UITableViewStylePlain];
    _table.delegate = self;
    _table.dataSource = self;
    [self.view addSubview:_table];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *di = _data[indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aaa"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"aaa"];
    }
    cell.textLabel.text = di[@"areaName"];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.textLabel.textColor = [UIColor grayColor];
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return _data.count;
}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 40;
//}
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
//{
//    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 50)];
//    view.backgroundColor = [UIColor whiteColor];
//
//    UILabel *la= [[UILabel alloc]initWithFrame:CGRectMake(10, 10, WIDTH-20, 30)];
//    [view addSubview:la];
//    la.font = [UIFont boldSystemFontOfSize:16];
//    la.text =_data[section][@"areaName"];
//
//    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 49, WIDTH, 1)];
//    [view addSubview:line];
//    line.backgroundColor = [UIColor colorWithHex:0xf2f2f2];
//    return view;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
//    return 50;
//}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *di = _data[indexPath.section];
    self.backType(di[@"areaName"]);
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
